const transSize = (sizeStr: string): number => {
    if (/^(\d*\.?\d+)(px|rem)?$/g.test(sizeStr)) {
        const [, value, unit] = /^(\d*\.?\d+)(px|rem)?$/g.exec(sizeStr);
        if (unit === 'rem') {
            return parseFloat(value) * (window.innerWidth / 10);
        }
        return parseFloat(value);
    }
    return 0;
};

const onResize = (width: string, height: string): string => {
    return `width:${transSize(width)}px;height:${transSize(height)}px;`;
};

export { transSize, onResize };
